//
//  QJManagerVC.m
//  QuanJieShopProject
//
//  Created by apple on 2018/1/30.
//  Copyright © 2018年 apple. All rights reserved.
//

#import "QJManagerVC.h"

@interface QJManagerVC () <UITabBarControllerDelegate>
//tabbar
@property (nonatomic, strong) UITabBarController *mainTabBarController;
//临时界面
@property (nonatomic, strong) UIView *containerView;
//是否弹出登录界面
@property (nonatomic, assign) BOOL ifShowLoginView;
@end

@implementation QJManagerVC

-(instancetype)initWithMainViewController:(UITabBarController *)mainVC{
    self = [super init];
    if (self) {
        _ifShowLoginView = NO;
        _mainTabBarController = mainVC;
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    //初始化界面
    [self initWithAppearance];
    
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.mainTabBarController.delegate = self;
    //隐藏导航栏
    self.navigationController.navigationBarHidden = YES;
}
#pragma mark -- 初始化界面
- (void)initWithAppearance{
    [self.view addSubview:self.containerView];
    if (self.mainTabBarController) {
        [self addChildViewController:self.mainTabBarController];
    }
}
#pragma mark -- UITabBarControllerDelegate
//判断点击的是哪一个控制器
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController NS_AVAILABLE_IOS(3_0){
    if(viewController == [tabBarController.viewControllers objectAtIndex:2]){
        //点击中间按钮的方法
        //从下向上弹出界面
        //        LZYLivePageVC *VC = [[LZYLivePageVC alloc]init];
        //        CATransition* transition = [CATransition animation];
        //        transition.duration = 0.25f;
        //        transition.type = kCATransitionMoveIn;
        //        transition.subtype = kCATransitionFromTop;
        //        [VC.view.layer addAnimation:transition forKey:kCATransition];
        //        [self.navigationController pushViewController:VC animated:NO];
        //        return NO;
        return YES;
    }
    return YES;
}

- (UIView *)containerView{
    if (!_containerView) {
        _containerView   = [[UIView alloc]initWithFrame:self.view.bounds];
    }
    return _containerView;
}
#pragma mark -- 重写 addChildViewController
- (void)addChildViewController:(UIViewController *)childController{
    [super addChildViewController:childController];
    [childController didMoveToParentViewController:self];
    [self.containerView addSubview:childController.view];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
